UPDATE
cscart_lock_keys
SET
expiry_at = UNIX_TIMESTAMP(NOW()) + 30,
token = 'B8hkCRh/eAly2lZd13nw0AAJ7SmkhE4kNGskVs9wc8Y='
WHERE
key_id = 'c9847831e621f97637a76a0c3bb8bd598af14e3c6fcc2275a0b9b3941e7507d3'
AND (
token = 'B8hkCRh/eAly2lZd13nw0AAJ7SmkhE4kNGskVs9wc8Y='
OR expiry_at <= UNIX_TIMESTAMP(NOW())
)